// $(document).ready(function () {

    $("#jqGrid").jqGrid({
        url: select_url + 'view_warn_report',
        editurl: edit_url + 'warn_report',
        mtype: 'POST',
        datatype: "json",
        colModel: [
            {
                label: '设备编号',
                name: 'deviceid',
                width: 100,
                key: true,
                editrules : { required: true},
                readonly:true,
                edittype:"select",
                editoptions: {
                    dataUrl:"http://192.168.1.233:3000/some/device",
                    // datatype:"json",
                    buildSelect: function (data) {
                        return data;
                    }
                }
            },
            {
                label : '设备名称',
                name: 'devicename',
                width: 100,
                // editable: true,
                readonly:true
            },
            {
                label : '报警类型',
                name: 'warn_type',
                width: 110,
                readonly: true,
                edittype:'select',formatter : 'select',
                editoptions : {
                    value:"0:不报警; 1:上限报警; 2:下限报警; 3:上下限报警"
                }
            },
            {
                label: '报警时间',
                name: 'time',
                width: 150,
                // editable: true,
                readonly: true,
                fixed: true, formatter: 'date',
                formatoptions: {srcformat:'Y-m-d H:i:s',newformat:'Y-m-d H:i:s'},
            },
            {
                label: '处理状态',
                name: 'handle_status',
                width: 100,
                editable: true,
                edittype:'select',formatter : 'select',
                editoptions : {
                    value:"1 : 已处理; 0 : 未处理"
                }
            },
            {
                label: '处理描述',
                name: 'memo',
                width: 280,
                editable: true,
                edittype:'textarea',formatter : 'textarea',
                editoptions : {
                    rows:"10",
                    cols:"52",
                    style:'height:auto!important'
                }
            },
            {//行编辑
                label: "操作",
                name: "actions",
                width: 100,
                formatter: "actions",
                formatoptions: {
                    keys: true,
                    editOptions: {},
                }       
            }
        ],

        jsonReader: {
            root: 'rows',
            repeatitems : false,
            id: "0"
        },
        rowNum:10,
        rowList:[10,20,30],
        sortname: 'deviceid',
        sortorder : 'desc',//倒序
        viewrecords: true,//记录数
        rownumbers: true, //行序号
        rownumWidth: 25,
        multiselect: true,//复选框
        width: 1000,
        height: 350,
        pager: "#jqGridPager",
        shrinkToFit: false
    });

    //弹框模板
    var template = "<div style='margin-left:15px;'><div> 处理状态 <sup>*</sup>:</div><div>{handle_status} </div>";
    template += "<div> 处理描述: </div><div>{memo} </div>";
    template += "<hr style='width:100%;'/>";
    template += "<div> {sData} {cData}  </div></div>";

    
    //分页
    $('#jqGrid').navGrid('#jqGridPager',
        // the buttons to appear on the toolbar of the grid
        { edit: true, add: false, del: false, search: false, refresh: true, view: false, position: "left", cloneToTop: false },
        // Edit Dialog
        {
            editCaption: "处理报警事件",
        }
    );

    //查询
    var deviceid_mask = $("#s_deviceId").val();
    var handle_mask = $("#s_handle").val();
    var timefrom_mask = $("#start-time").val();
    var timeto_mask = $("#end-time").val();
    gridReload("view_warn_report?deviceid="+deviceid_mask+"&timeform="+timefrom_mask+"&timeto="+timeto_mask);

    
// });